home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DATATYPE.SWG / 0011_UNTYPED.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  954b  |  39 lines

  1. {
  2. > It would be Really nifty if it were possible to have InVar be
  3. > unTyped in the Function, so that the call would pass the Type,
  4. > but I can't figure this one out.
  5.  
  6. Here is a small sample of code that demonstrates how to do what (I
  7. think) you're wanting to do:
  8. }
  9.  
  10. Type
  11.   TypeID = (tByte, tInt, tLong, tReal, tStr);
  12.  
  13. Procedure MultiType(Var InVar; InType : TypeID);
  14.  
  15. Var
  16.   b : Byte Absolute InVar;
  17.   w : Integer Absolute InVar;
  18.   i : LongInt Absolute InVar;
  19.   r : Real Absolute InVar;
  20.   s : String Absolute InVar;
  21.  
  22. begin
  23.   Case InType of
  24.     tByte : WriteLn('Byte = ',b);
  25.     tInt  : WriteLn('Integer = ',w);
  26.     tLong : WriteLn('LongInt = ',i);
  27.     tReal : WriteLn('Real = ',r);
  28.     tStr  : WriteLn('String = ',s);
  29.     else    WriteLn('Unknown Type!');
  30.   end;
  31. end;
  32.  
  33. {
  34. of course, the above is just an example and it doesn't actually
  35. do anything useful, but you should be able to adapt it to suit
  36. your purposes.
  37. }
  38.  
  39.